package vpfarm.master;

import jtools.ai.agenten.AMessage;
import jtools.ai.agenten.CycleBehavior;
import vpfarm.Constants;
import vpfarm.data.JobInfo;

public class WaitForJobBehavior extends CycleBehavior {

	
	private Master master;

	public WaitForJobBehavior(Master master) {
		this.master = master;
	}

	public void execute() {
		AMessage amsg = myAgent.reciveMessage(true);
		if (amsg == null)
			return ;
		if (amsg.getSubject() == Constants.SEND_JOB_INFO){
			System.out.println("erhalte JobInfo");
			this.master.addJob((JobInfo) amsg.getContent());
		}
		else
			myAgent.pushBack(amsg);
	}

	@Override
	public void onEnd() {
	}

	public void onStart() {
	}

}
